package com.project.controller;

import com.github.pagehelper.PageInfo;
import com.project.entity.Order1;
import com.project.entity.RestPOJO;
import com.project.service.impl.OrderServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@Api(tags = "出租户订单管理")
public class OrderController {
    @Autowired
    private OrderServiceImpl orderService;

    @ApiOperation(
            value = "查找当前用户的ID",
            httpMethod = "POST",
            protocols = "HTTP",
            produces = "application/json",
            response = RestPOJO.class
    )
    @PostMapping("/getOrdersByUid")
    public RestPOJO getOrderByUid(@RequestBody Map<String,String> map){
        RestPOJO restPOJO = new RestPOJO();
        Integer uid =Integer.parseInt(map.get("uid"));
        Integer pageSize = Integer.parseInt(map.get("currentPage"));
        Integer currentPage = Integer.parseInt(map.get("pageSize"));
        String stall_code =map.get("stall_code");
        PageInfo<Order1> pageInfo = orderService.getAllOrderByUid(uid,pageSize,currentPage,stall_code);
        if (pageInfo.getList().size()>0){
            restPOJO.setStatus(1000);
            restPOJO.setMessages("查询成功");
            restPOJO.setData(pageInfo);
        }else{
            restPOJO.setStatus(1001);
            restPOJO.setMessages("查询失败");
            restPOJO.setData(pageInfo);
        }
        return restPOJO;
    }

}
